package jsu.blogger;

import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.seg.common.Term;
import jsu.blogger.mapper.PostMapper;
import jsu.blogger.util.KeywordExtractor;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class testKeyWord {

    @Autowired
    private PostMapper postMapper;
    @Test
    void testKey(){
        String text = "今天天气很好，我们去公园玩吧！";
        int topN = 3;

        List<String> keywords = KeywordExtractor.extractKeywords(text, topN);
        System.out.println("Top " + topN + " keywords: " + keywords);
        System.out.println(postMapper.selectPostIdsByKeywordsList(keywords));
    }
}
